################################################################
#                                                              #
# Disclaimer: it is recommended to run the scripts in the same #
# order as listed. Otherwise, some dependencies will not work  #
#                                                              #
################################################################


### Set a working directory if you did not store the scripts and files in a project ### 
# setwd("***") #



#########################  H3 #################################
### Load ESS Wave 10 into the workspace ###
load("ESSten.RData")

### Load packages ###
source("Packages.R", print.eval=TRUE)

### Plot Google trends ###
source("Google Trends.R", print.eval=TRUE)

### Recode relevant ESS10 variables ###
source("Recode Variables.R", print.eval=TRUE)

### Plot interview density ### 
source("Interview Density.R", print.eval=TRUE)

### Plot Immigration Attitudes in ESS10 ###
source("Descriptive Plots.R", print.eval=TRUE)

### RDD Main Specification ###
source("RDD Main.R", print.eval=TRUE)

### OLS Specification ###
source("OLS.R", print.eval=TRUE)

### RDD Alternative Outcome ###
source("RDD Alt.R", print.eval=TRUE)

### Robustness Checks ###
source("Bandwidth Tests.R", print.eval=TRUE) ### This particular script takes a long time to run on most machines, 
                                             ### so you might want to run the lines for individual bandwidth 
                                             ### plots separately instead of running the whole script.
source("Manual Bandwidths.R", print.eval=TRUE)
source("Fake Cutoff Placebos.R", print.eval=TRUE)
source("Unrelated Outcome Placebos.R", print.eval=TRUE)
source("Covariate Balance Tests.R", print.eval=TRUE)
source("Alternative Specifications.R", print.eval=TRUE)
source("McCrary Test.R", print.eval = TRUE)

### Heterogeneous Treatment Effects ###
source("Heterogeneous Effects.R", print.eval=TRUE)


########################## H1 / H2 ############################

### Topic Models ###
source("Topic Models.R", print.eval = TRUE) # script takes a long time to run

### Sentiment Analyses
source("Sentiment Analyses.R", print.eval = TRUE) # script takes a long time to run

### Text-as-Data Plots ###
source("TADplots.R", print.eval = TRUE)

### Ukraine Factiva Analyses ###
source("Ukraine Analyses.R", print.eval = TRUE)

### Correlations in qualitative coding ###
source("Correlations.R", print.eval = TRUE)
